package logic

import (
	"bilibili/bilibilirpc/bilibilirpc"
	"bilibili/bilibilirpc/internal/svc"
	"bilibili/models/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserRealnameAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserRealnameAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserRealnameAddLogic {
	return &UserRealnameAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserRealnameAddLogic) UserRealnameAdd(in *bilibilirpc.UserRealnameAddRequest) (*bilibilirpc.UserRealnameAddResponse, error) {
	// todo: add your logic here and delete this line
	user := mysql.UserRealnameAdd{
		UserRealname: mysql.UserRealname{
			Name:   in.Name,
			Idcard: in.IdCard,
			Status: in.Status,
		},
		Mobile:   in.Mobile,
		Password: in.Password,
	}
	mysql.DB.Debug().Create(&user)
	return &bilibilirpc.UserRealnameAddResponse{
		Id: int64(user.ID),
	}, nil
}
